home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Swar / stars.c < prev    next >
Text File  |  1994-08-21  |  632b  |  32 lines

  1.  
  2. #include "swar.h"
  3.  
  4. InitStars()
  5. {
  6.     extern STARREC        gStarRecs[MAX_STARS];
  7.     short                    i;
  8.     
  9.     for (i = 0; i < MAX_STARS; i++) {
  10.         gStarRecs[i].where.v = RngRnd(0, 479);
  11.         gStarRecs[i].where.h = RngRnd(0, 639);
  12.         gStarRecs[i].color.red = -1;
  13.         gStarRecs[i].color.green = -1;
  14.         gStarRecs[i].color.blue = -1;
  15.     } /* for */
  16.  
  17. } /* InitStars() */
  18.  
  19. DrawStars()
  20. {
  21.     short                i;
  22.     GrafPtr                savePort;
  23.     extern CGrafPort    *gOSPtr;
  24.     
  25.     GetPort(&savePort);
  26.     SetPort((GrafPtr)gOSPtr);
  27.     for (i = 0; i < MAX_STARS; i++) {
  28.         SetCPixel(gStarRecs[i].where.h, gStarRecs[i].where.v, &(gStarRecs[i].color));
  29.     } /* for */
  30.     SetPort(savePort);
  31.     
  32. } /* DrawStars() */